<?php

namespace app\index\controller;

use Endroid\QrCode;
use app\common\controller\Frontend;
class Util extends Frontend{

    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';

    /**
     * 显示一个用base64加密的字符串
     * @param $str
     * @return \think\Response
     */
    public function qrcode_base64($str){
        $hi = "hello boy";
        if ($str == base64_encode(base64_decode($str))){
            $hi = base64_decode($str);
        }
        $qr = new QrCode\QrCode($hi);
        return response()->header(['Content-Type'=>$qr->getContentType()])->data($qr->writeString());
    }

}

